package org.rpc.util;

import org.rpc.common.Environment;
import org.yaml.snakeyaml.Yaml;


/**
 * @author tzf
 * @description: 读取配置文件, 获取端口和contextPath
 * @date: 2023/11/17 17:41
 */

public class EnvironmentUtil {
    private static Environment environment = new Environment();

    public static void init() {
        Yaml yaml = new Yaml();
        environment = yaml.loadAs(Class.class.getResourceAsStream("/application.yml"), Environment.class);
        System.out.println(environment.toString());
    }

    public static void main(String[] args) {
        init();
    }

    public static int getPort() {
        return environment.getServer().getPort();
    }

    public static String getContextPath() {
        return environment.getServer().getContextPath();
    }
}
